package cn.xp.feign;

import cn.xp.domain.User;
import cn.xp.fallback.UserFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @Description feign请求user服务的客户端
 * @Author xp
 * @Date 2023/4/14 11:45
 * @Version 1.0
 */
@FeignClient(value = "user-server",fallbackFactory = UserFeignClientFallbackFactory.class) // 表示是feign接口")//想调用那个接口的服务名,根据服务名找接口
public interface UserFeignClient {

    //调用的接口需要和被调用的接口的请求方式、请求参数、请求地址、返回值类型保持一致
    @GetMapping("/user/{id}")
    public User getById(@PathVariable("id") Long id);
}